﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Operator_RefillBankAccount : System.Web.UI.Page
{
    BankDataDataContext db = new BankDataDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {;
        string bankAccountId = null;
        if (Session["bankAccountId"] != null)
        {
            bankAccountId = Session["bankAccountId"].ToString();
        }
        if (bankAccountId != null)
        {
            var bankAccounts = from bankAccount in db.BankAccounts where bankAccount.BankAccountId == Convert.ToInt32(bankAccountId) select bankAccount;
            AmountLabel.Text = "Сумма (" + bankAccounts.First().Currency.Name +")";
        }
    }

    protected void RefillButton_Click(object sender, EventArgs e)
    {
        string bankAccountId = null;
        if (Session["bankAccountId"] != null)
        {
            bankAccountId = Session["bankAccountId"].ToString();
        }
        if (bankAccountId != null)
        {
            var bankAccounts = from bankAccount in db.BankAccounts where bankAccount.BankAccountId == Convert.ToInt32(bankAccountId) select bankAccount;
            bankAccounts.First().Amount += Convert.ToDecimal(Amount.Text);
            db.SubmitChanges();
            Response.Redirect("~/Operator/BankAccounts.aspx");
        }
    }
}